<%--
 *  File:    ProtocolManagement.jsp	
 *  @Author: banshang
 *  Date:    2010/07/20
 *
 *  Copyright (C) 2000 - 2008 Oval Technologies, Inc.
 *  All rights reserved. 
 *
 *  This software is the confidential and proprietary information of Oval 
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>

<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/oval-tag.tld" prefix="oval"%>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom"%>

<%
	
  //init param
  String privilegeCode = "11201";
  String strTableName = "v_protocolmanage";
  
  String strModuleName = "COM";
  String contextPath = request.getContextPath();
%>
<%@ include file="/inc/CommonHeader.inc"%>
<%@ include file="/inc/OvalLocationDefault.inc"%>
<%@ include file="/inc/Print.inc"%>

<html>
<head>
<title>ProtocolManagement</title>
<PageFlow:CheckPageFlow pageName="p_protocolsummary" />
<%@ include file="/inc/CatchError.inc"%>
<%@ include file="/inc/SumDiv.inc"%>

<link rel="stylesheet" href="<%=contextPath%>/css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath%>/css/cn/script.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/ScriptLib.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/SummaryDivision.js"></script>

<script language="JavaScript">
<%--  put your custom script here   --%>
function page_summary(actionvalue,orderbyname)
{
  var editform = summaryPrepare(cform,actionvalue,orderbyname);
  if(!editform) return;
  editform.action = "ProtocolManagement.jsp?<%= OvalTools.randomURL() %>";
  editform.target = "_self";
  isRunning = true;
  editform.submit();
}

function page_edit()
{
	var protocolid = document.cform.protocolid.value;
	var status = document.cform.status.value;
	if(status != 10){
		alert("<%= message.getMessageDesc("CAN_NOT_EDIT_IT") %>");
		return;
	}
	self.location.href="ProtocolEditFrm.jsp?<%= OvalTools.randomURL() %>&protocolid="+protocolid;
}

function page_new()
{
    self.location.href="ProtocolEditFrm.jsp?<%= OvalTools.randomURL() %>";
}

function page_delete()
{
	var status = document.cform.status.value;
	if(status != 10){
		alert("<%= message.getMessageDesc("CAN_NOT_BE_DEL") %>");
		return;
	}
    if(!confirm("<%= message.getMessageDesc("ARE_YOU_SURE_DEL") %>")) return;
    cform.actionname.value = "delete";
    cform.target = "_self";
    isRunning = true;
    cform.submit();
}
function clickonerow(obj,id,status){
	obj.all.protocol.checked = true;
	document.cform.protocolid.value=id;
	document.cform.status.value=status;
}
function popOrg(flag) {
	var opt="";
	if(isEmpty(document.cform.protocoltype.value))
    {
        alert("<%= message.getMessageDesc("Please_Choose_The_Type_Of_Agreement") %>");		
        return;
    }
	if(flag == 1)
	{
			opt = "1";
	}else
	{
			opt = "2";
	}
  var status = "height=400, width=600, top=100, left=100, toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, status=no";
		var url = "SelectClient.jsp?o_thread=" + Math.random();
		url += "&selectoption=distributor&orgglobalpccode=100";
		url += "&opt=" + opt;
		url += "&protocoltype="+document.cform.protocoltype.value;
		if (typeof popwindow != 'undefined') popwindow.close();
		popwindow = window.open(url, "newwindow", status);
}


function page_test(){
	cform.actionname.value = "test";
    cform.target = "_self";
    isRunning = true;
    cform.submit();
}

function showPopWindow (pagename){
	var status = "height=250, width=600, top=100, left=100, toolbar=yes, menubar=yes, scrollbars=yes, resizable=yes, location=yes, status=yes";
	var url = pagename+'?<%= OvalTools.randomURL() %>';	
	popwindow = window.open(url, "newwindow", status);
}

function popSelectRegionWindow(){
	 showPopWindow ('../ogm/RegionPopWindow.jsp');	
}

function showPopProWindow (pagename,areaidString){
	var status = "height=250, width=600, top=100, left=100, toolbar=yes, menubar=yes, scrollbars=yes, resizable=yes, location=yes, status=yes";
		var url = pagename+'?<%= OvalTools.randomURL() %>' + '&areaidstring=' + areaidString;
		
	popwindow = window.open(url, "newwindow", status);
}

function popSelectProWindow(){
		 var areaname = document.cform.areaname.value;
		 var areaidString = document.cform.areaids.value;
		 if(areaname == "" || areaname.length == 0){
			alert("请选择大区！");
		 	document.cform.areaname.focus();
		 	return;
		 }
		 showPopProWindow ('../ogm/ProvincePopWindow.jsp',areaidString);
}

function setNewAreaCode(newareacode,areaname,areacode){
	var length = newareacode.length;
	var areaidString = "";
	var areanameString = "";
	var areacodeString = "";
	document.cform.areaname2.value = "";
	document.cform.areaids2.value = "";	
	for(var i = 0;i < length;i++){
		if(i == length - 1){
			areaidString = areaidString + newareacode[i].value;
			areanameString = areanameString + areaname[i].value;
			areacodeString = areacodeString+ areacode[i].value;
		}else{				
			var code = newareacode[i];				
			areaidString = areaidString + newareacode[i].value + ",";
			areanameString = areanameString + areaname[i].value + ",";
			areacodeString = areacodeString + areacode[i].value + ",";
		}			
	}	
	document.cform.areaname.value = areanameString;
	document.cform.areaids.value = areaidString;	
}
function setNewRegionCode(newareacode,areaname2,areacode2){
	var length = newareacode.length;
	var areaidString = "";
	var areanameString = "";
	var areacodeString = "";
	for(var i = 0;i < length;i++){
		if(i == length - 1){
			areaidString = areaidString + newareacode[i].value;
			areanameString = areanameString + areaname2[i].value;
			areacodeString = areacodeString+ areacode2[i].value;
		}else{				
			var code = newareacode[i];				
			areaidString = areaidString + newareacode[i].value + ",";
			areanameString = areanameString + areaname2[i].value + ",";
			areacodeString = areacodeString + areacode2[i].value + ",";
		}			
	}
	
	document.cform.areaname2.value = areanameString;
	document.cform.areaids2.value = areaidString;	
}
function page_copy(){
	if(!confirm("<%= message.getMessageDesc("ARE_YOU_SURE_COPY") %>")) return;
	cform.actionname.value = "copy";
    cform.target = "_self";
    isRunning = true;
    cform.submit();
}	
</script>
</head>

<body >
<form name="cform" method="post" action="<%=contextPath%>/Dispatcher"><input
	type="hidden" name="pagename" value="p_protocolsummary"> <input
	type="hidden" name="actionname"> <input type="hidden" name="name"
	value=""> <input type="hidden" name="type" value="">
<%--  page location   --%>

<%@ include file="/inc/PageLocation.inc"%>

<table width="100%" cellspacing="0" border="0" cellpadding="0">
	
	<tr>
		<td>
		<table width="100%" border="0" cellspacing="0">
			<%@ include file="/inc/SummarySearch.inc"%>
		</table>
		</td>
	</tr>
	<tr>
		<td>
		<table width="100%" border="1" cellpadding="0"
			bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0"
			align="center">
			<tr class="deepblue-left">
				<td width="22" class="title_center">&nbsp;</td>
				<td class="title_center" width="150"><a
					href="javascript:page_summary('orderby','protocolcode')"><%= label.getLabelName("L_ProtocolCode") %></a></td>
				<td class="title_center" width="250"><a
					href="javascript:page_summary('orderby','protocolname')"><%= label.getLabelName("L_ProtocolName")%></a></td>
				<td class="title_center" width="200"><a
					href="javascript:page_summary('orderby','protocoltypename')"><%=label.getLabelName("L_AgreementType") %></a></td>
				<td class="title_center" width="120"><a
					href="javascript:page_summary('orderby','shortname')"><%= label.getLabelName("L_FirstOrg")%></a></td>
				<td class="title_center" width="200"><a
					href="javascript:page_summary('orderby','secondorgname')"><%= label.getLabelName("L_SecondOrg")%></a></td>
				<td class="title_center" width="200"><a
					href="javascript:page_summary('orderby','thirdorgname')"><%= label.getLabelName("L_ThirdOrg")%></a></td>
				<td class="title_center" width="120"><a
					href="javascript:page_summary('orderby','startdate')"><%= label.getLabelName("L_BeginDate")%></a></td>
				<td class="title_center" width="120"><a
					href="javascript:page_summary('orderby','enddate')"><%= label.getLabelName("L_EndDate")%></a></td>
				<td class="title_center" width="80"><a
					href="javascript:page_summary('orderby','status')"><%= label.getLabelName("L_Status")%></a></td>
			</tr>
			<%
				Vector protocols = (Vector)pageContext.getAttribute("protocols");
				if(protocols == null)
					protocols = new Vector();
		
		       String strClassType = "";
		       String strChecked = "";
		       boolean bHasChecked = false;
		
		       Integer nDefaultProtocolid = new Integer(-1);
		      
		
		       Integer nStatus = new Integer(-1);
		       int i = 0;
		
		    %>
			<%--  the old detail lines  --%>

		
			<logic:iterate id="onerow" collection="<%= protocols %>" indexId="idx">
			<%
                HashMap protocol = (HashMap)pageContext.getAttribute("onerow");
	            if(i%2 == 1)
	        	  {
	        	    strClassType = "td-listrom";
	        	  }else{                    
	        	    strClassType = "none";
	        	  }
	            if (!bHasChecked)
	 	       {
	            	nDefaultProtocolid = (Integer)(protocol.get("protocolid"));
	 	             
	            	nStatus = (Integer)(protocol.get("status"));  
	 	         
	 	         bHasChecked = true;
	 	         strChecked = "Checked";
	 	       }
	 	       else
	 	       {
	 	         strChecked = "";
	 	       }
	        	i++;
            %>
				<tr onMouseOver="this.className='tr-over'"
					onMouseOut="this.className='<%=strClassType%>'"
					class="<%=strClassType%>"
					onclick="clickonerow(this,'<custom:write property="protocolid" name="onerow"/>','<custom:write property="status" name="onerow"/>')">
					<td>
						<input <%= strChecked %> type="radio" name="protocol" value="<custom:write name="onerow" property="protocolid"/>" class="normalradio">
					</td>
					<td>&nbsp;<a href="ProtocolInfoFrm.jsp?<%= OvalTools.randomURL() %>&protocolid=<custom:write name="onerow" property="protocolid"/>"/><custom:write property="protocolcode" name="onerow" nbsp="true" /></a></td>
					<td><custom:write property="protocolname" name="onerow" nbsp="true" /></td>
					<td><custom:write property="protocoltypename" name="onerow" nbsp="true" /></td>
					<td><custom:write property="shortname" name="onerow" nbsp="true" /></td>
					<td><custom:write property="secondorgname" name="onerow" nbsp="true" /></td>
					<td><custom:write property="thirdorgname" name="onerow" nbsp="true" /></td>
					<td><custom:write property="startdate" name="onerow" nbsp="true" dataType="date" dataFormatName="dateformat"/></td>
					<td><custom:write property="enddate" name="onerow" nbsp="true" dataType="date" dataFormatName="dateformat"/></td>
					<td><custom:write property="status" dictType="Status" name="onerow" nbsp="true"/></td>

				</tr>

			</logic:iterate> 
			
			<%@ include file="/inc/SummaryAction.inc"%>
		</table>
		<input type="hidden" name="protocolid" value="<%= nDefaultProtocolid %>"/>
		<input type="hidden" name="status" value="<%= nStatus%>"/>
		<table width="100%" cellspacing="0" cellpadding="0">
			<tr>
				<td class="summary_top"></td>
			</tr>
			<tr>
				<td class="td_center"><a onclick="page_new();"><custom:button
					type="1" label="L_New" imgsrc="new.gif" border="0" style="width:60" /></a>
					 <a onclick="page_edit()"><custom:button type="1" label="L_Edit" imgsrc="edit.gif" border="0" style="width:60" /></a> 
					 <!-- 
					 <a onclick="page_copy()"><custom:button type="1" label="L_Copy" imgsrc="edit.gif" border="0" style="width:60" /></a>
					 -->
					 <a onclick="page_delete()"><custom:button type="1" label="L_Delete" imgsrc="delete.gif" border="0" style="width:60" /></a> 
				</td>
			</tr>
          </table>
        </td>
      </tr>
    </table>
</form>
</body>
</html>